Compressing textures
Kanzi supports ATC, ETC, and PVRTC algorithms for texture compression. If your target hardware supports any of these compression methods, you can greatly reduce the memory bandwidth of your application by using texture compression. Kanzi applications send compressed textures directly to the GPU, reducing the amount of interchanged data and without preprocessing on the CPU side (for example, loading libJPEG or libPNG). For example, a 256 by 256 pixels RGB texture uses 196 kb (256 * 256 * 3). When compressed with ETC, the same texture uses 32 kb (256 * 256 / 2).
If your target hardware does not support any of these compression algorithms, in some cases raw image format can be faster than any compression algorithm. This is particularly true when processing single small images.
Because OpenGL expects .dxt texture data to have bottom row first, compress .dxt files vertically flipped. Note that you can use the .dxt files in your Kanzi application, but the .dxt files are not supported in the Win32 emulation because of GPU limitations. See Preparing .dds images for use in Kanzi applications.
Using the ETC compression
Kanzi supports ETC according to the ETC1 scheme, so the alpha channel is not directly supported. However, you can use alpha channel with ETC compression using a workaround. See ETC Texture Compression and Alpha Channel Handling.
To use ETC compression in Kanzi Studio:
- In the Library select Resource Files > Images, and select the image for which you want to apply compression.
- In the Properties set the Target Format property to one of the ETC compressions:
- Fast, medium, and slow refer to the speed of image compression. Kanzi Studio compresses images when you create a Kanzi application.
The values correspond to the compression time and image quality, not to the resulting size or decompression time. Slow returns the best image quality.
- Perceptual refers to the emphasis of green color channel over red and blue color channels, based on the human visual system color affinity.
For the best final result use slow perceptual. During development fast is the most useful.
Using the ATC compression
To use ATC compression in Kanzi Studio:
-
In the Library select Resource Files > Images, and select the image for which you want to apply compression.
- In the Properties set the Target Format property to ATC.
- Set the ATC Compression Scheme property to:
- Explicit alpha. RGBA image, where alpha component is explicit on each pixel, data compressed to pixel_count / 1, giving 1:4 compression ratio.
- Interpolated alpha. RGBA image, where alpha component is interpolated between pixels, data compressed to pixel_count / 1, giving 1:4 compression ratio.
- No alpha. RGB image, data compressed to pixel_count / 2, giving 1:6 compression ratio.
Using the PVRTC compression
The PVRTC algorithm works best for photorealistic textures. Kanzi supports PVRTC according to the PVRTC1 and PVRTC2 schemes. PVRTC2 has higher quality than PVRTC1, especially with textures requiring sharp alpha transitions, but it is not supported by all PowerVR hardware. Additionally, only Imagination Technologies hardware, or a desktop platform using a development emulator support PVRTC compression.
When using PVRTC to compress textures, to get correct results, the textures must be square and the power of two in size.
To use PVRTC compression in Kanzi Studio:
- In the Library select Resource Files > Images, and select the image for which you want to apply compression.
- In the Properties set the Target Format property to PVRTC, then set:
- PVRTC Bit Depth to either:
- 2 bits/pixel results in smaller, but lower quality textures.
- 4 bits/pixel results in larger, but higher quality textures. With 4 bits/pixel bit depth the texture file size is twice as big as in 2 bits/pixel texture, but it results in a higher quality texture.
- PVRTC Encoding Quality to either Fastest, Fast, Normal, High, or Best.
These values correspond to the compression time and image quality, not to the resulting size or decompression time. For the best final result use Best. During development Fastest is the most useful. - PVRTC Compression Scheme to either PVRTC1 or PVRTC2. Both schemes support RGB and RGBA textures. Kanzi automatically uses RGBA for all images that contain the alpha channel.
- Premultiply Alpha. Select True if you want to premultiply the alpha channel into color channels in images that have an alpha channel, otherwise select False. Select Project default if you want to control the value of this property by the Kanzi Studio project property Use Premultiplied Alpha by Default.
Preprocessing images
You can compress images and generate mipmaps before exporting your Kanzi application.
To preprocess images in Library select one or more images you want to preprocess, right-click and select Preprocess images.
See also
Adjusting the data size
Loading resources in parallel
Using mipmaps
Filtering textures
Measuring the performance of your Kanzi application
Images and textures best practices
Best practices
Images
Open topic with navigation